/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.example;

import java.util.Random;
import java.util.UUID;

/**
 * <p>Project: javaseapp - Random1
 * <p>Powered by webrx On 2021-07-28 17:13:45
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Random1 {
    public static void main(String[] args) {
        //随机id(UUID)
        UUID id = UUID.randomUUID();
        System.out.println(id);
        System.out.println(id.toString().length());//36
        //19485389-9d53-4466-8886-82863d1c2085
        //093c3b05-67fb-4a70-9763-ac6d739d46cb.jpg

        //随机类Random
        Random rand = new Random();
        //true false 真假随机
        System.out.println(rand.nextBoolean());//false true

        //0 - 5随机整数
        System.out.println(rand.nextInt(6));

        //Math.random() 返回double

        //随机颜色
        int rr = rand.nextInt(256);
        int gg = rand.nextInt(256);
        int bb = rand.nextInt(256);
        System.out.printf("#%02x%02x%02x%n",rr,gg,bb);

        System.out.println(rand.nextDouble());
        System.out.println(rand.nextFloat());
        System.out.println(rand.nextLong());
        System.out.println(rand.nextInt());

        System.out.println(rand.nextGaussian());

    }
}
